package com.xnfh.equipment.weight

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import com.xnfh.common.bean.WeatherMessageBean
import com.xnfh.equipment.R

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2023/11/2 4:46 PM
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/11/2 4:46 PM
 * @UpdateRemark: 更新说明
 */
class WeatherOneTabView : FrameLayout {
    constructor(context: Context?) : super(context!!) {
        init()
    }

    constructor(context: Context?, attrs: AttributeSet?) : super(
        context!!, attrs
    ) {
        init()
    }

    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context!!, attrs, defStyleAttr
    ) {
        init()
    }

    private var headerName: TextView? = null
    private var key1: TextView? = null
    private var value1: TextView? = null
    private fun init() {
        LayoutInflater.from(context).inflate(R.layout.item_weather_onetab_layout, this)
        headerName = findViewById<View>(R.id.in_item_one_tab_weather_title) as TextView
        key1 = findViewById<View>(R.id.in_item_one_tab_weather_name) as TextView
        value1 = findViewById(R.id.in_item_one_tab_weather_value)
    }

    fun setValue(data: List<WeatherMessageBean>) {
        if (data.isEmpty()) return
        headerName!!.text = data[0].DeviceModel
        key1!!.text = data[0].deviceName + "(" + data[0].unit + ")"
        value1!!.text = data[0].sensorValue.toString()
    }
}